#ifndef __LCD_H
#define __LCD_H

#include <ioCC2530.h>

typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;

#define RED 0xf800
#define GREEN 0x07e0
#define BLUE 0x001f
#define WHITE 0xffff
#define BLACK 0x0000
#define YELLOW 0xFFE0

#define CYAN 0x07ff
#define BRIGHT_RED 0xf810

#define GRAY0   0xEF7D   	
#define GRAY1   0x8410      
#define GRAY2   0x4208      

#define X_MAX_PIXEL 128
#define Y_MAX_PIXEL 128


#define LCD_CS_SET do{P1_3 = 1;}while(0)
#define LCD_RS_SET do{P1_7 = 1;}while(0)
#define LCD_SDA_SET do{P1_6 = 1;}while(0)
#define LCD_SCL_SET do{P1_5 = 1;}while(0)
#define LCD_LED_SET do{P2_0 = 1;}while(0)

#define LCD_CS_CLR do{P1_3 = 0;}while(0)
#define LCD_RS_CLR do{P1_7 = 0;}while(0)
#define LCD_SDA_CLR do{P1_6 = 0;}while(0)
#define LCD_SCL_CLR do{P1_5 = 0;}while(0)
#define LCD_LED_CLR do{P2_0 = 0;}while(0)

void delay1ms(void);   //误差 -0.25us

void Lcd_Init(void);
void Lcd_WriteIndex(uint8_t Index);
void Lcd_WriteData(uint8_t Data);
void Lcd_WriteReg(uint8_t Index, uint8_t Data);
uint16_t Lcd_ReadReg(uint8_t LCD_Reg);
void Lcd_Reset(void);
void Lcd_Clear(uint16_t Color);
void Lcd_SetXY(uint16_t x, uint16_t y);
void Gui_DrawPoint(uint16_t x, uint16_t y, uint16_t Data);
unsigned int Lcd_ReadPoint(uint16_t x, uint16_t y);
void Lcd_SetRegion(uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end);
void LCD_WriteData_16Bit(uint16_t Data);
void showimage(const unsigned char *p);
void Lcd_ReadID(void);
void showimage_farsight(const unsigned char *p);
void Gui_DrawFont_GBK16(uint16_t x, uint16_t y, uint16_t fc, uint16_t bc, uint8_t *s);

#endif
